<template>
  <div>
    <el-button @click="closeDrawer()" size="small" type="primary">模板下载</el-button>
    <div style="margin-top:20px;"></div>
    <importFile :title="'导入'" :actionUrl='`${uploadPrefix}/api/cmscloud.wholesales/DiscountRuleSettings/importRule`' @close="closeHandler" />
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    ></div>
  </div>
</template>
<script>
import { downloadUrl,exportExcelFile } from '@/utils'
import { excelList1 } from '@/api/omSaleP/vehicleParameters/vehicleSpecialPrice/index.js';
import moment from 'moment';
import config from '@/assets/js/config';
export default {
  data() {
    return {
      uploadPrefix: config.uploadUrl,
      fetchParams: {},
      fetchApi: () => {}
    };
  },
  methods: {
    closeDrawer(type) {
      this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
        confirmButtonText: '下载',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {

        let json = this.fetchParams;
        this.exportLoading = true;
        excelList1(json)
          .then(response => {
            exportExcelFile(response.data, '折扣政策导入');
            this.exportLoading = false;
          })
          .catch(err => {
          
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
    },
    closeHandler(val) {
      this.$emit('close')
    },
  }
};
</script>
